var doc_lookup = new Array();

function loadHash(link) {
	$('#nav > h2 > a').attr('class','');
	$('#'+link).attr('class','selected');
	if(doc_lookup[link] != null) {
		$('div.details').fadeOut('50',function(){
			$(this).html(doc_lookup[link]).fadeIn('50');
			$(this).attr('id',link);
		});
	} else {
		$.ajax({
			url: '/resume/'+link,
			beforeSend: function() {
				$('div.details').html('<div class="loader"></div>');
			},
			success: function(data) {
				doc_lookup[link] = data;
				$('div.details').fadeOut('50',function(){
					$(this).html(data).fadeIn('50');
					$(this).attr('id',link);
				});
			},
			error: function() {
				$('div.details').html('<p>Whoa! 404! Try clicking <a href="/resume/">this link</a> to go back to the start of the Resume page');
			}
		});
	}
}

String.prototype.toURL = function() {
	var str = this.toLowerCase();
	var url = str.replace(/ /g,'-');
	return url;
};

$(document).ready(function() {
	var hash = window.location.hash.substring(1);
	if(hash != '') {
		loadHash(hash);
	}
});